/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.gen2phen.labs.domain;

import java.util.HashMap;

/**
 *
 * @author pedrolopes
 *
 * GEN2PHEN Semantic Web Labs: Knowledge Netowork
 *
 */
public class Gene {

    private String symbol;
    public HashMap<String, Disease> diseases = new HashMap<String, Disease>();

    public HashMap<String, Disease> getDiseases() {
        return diseases;
    }

    public void setDiseases(HashMap<String, Disease> diseases) {
        this.diseases = diseases;
    }

    public String getSymbol() {
        return symbol;
    }

    public void setSymbol(String symbol) {
        this.symbol = symbol;
    }

    public Gene(String symbol) {
        this.symbol = symbol;
    }

    /**
     * Associates a given Disease with the Gene
     *
     * @param d The Disease.
     * @return Success of the operation.
     */
    public boolean addDisease(Disease d) {
        boolean success = false;

        try {
            diseases.put(d.getName(), d);   // add Disease to the Gene's disease HashMap
            success = true;
        } catch (Exception e) {
            System.out.println("[Gene] error " + e.toString());
        }

        return success;
    }

    /**
     * Overrident toString method to include information about associated Diseases and Drugs.
     * 
     * @return
     */
    @Override
    public String toString() {
        String response = this.symbol;

        for (Disease d : diseases.values()) {
            response += d.toString();
        }
        return response;
    }
}
